///
/// Copyright (C) 2018, Cyberhaven
/// All rights reserved.
///
/// Licensed under the Cyberhaven Research License Agreement.
///

#ifndef S2E_PLUGINS_FilePovGenerator_H
#define S2E_PLUGINS_FilePovGenerator_H

#include <s2e/CorePlugin.h>
#include <s2e/Plugin.h>
#include <s2e/S2EExecutionState.h>

#include <s2e/Plugins/ExecutionTracers/TestCaseGenerator.h>

#include "PovGenerator.h"

namespace s2e {
namespace plugins {
namespace pov {

class FilePovGenerator : public PovGenerator {
    S2E_PLUGIN
public:
    FilePovGenerator(S2E *s2e) : PovGenerator(s2e) {
    }

    void initialize();

    virtual bool generatePoV(S2EExecutionState *state, const PovOptions &opt, const std::string &filePrefix,
                             std::vector<std::string> &filePaths);

private:
    testcases::TestCaseGenerator *m_tc;

    uint64_t m_gp;
    uint64_t m_pc;

    void assignNegotiatedVariables(std::unordered_map<std::string, uint8_t> &varAssignment, const PovOptions &opt);

    void constrainNegotiatedVariables(S2EExecutionState *state, std::unordered_map<std::string, uint8_t> &varAssignment,
                                      PovOptions &opt);
};

} // namespace pov
} // namespace plugins
} // namespace s2e

#endif // S2E_PLUGINS_FilePovGenerator_H
